<?php 
include '../utils/stock.php';
include '../utils/evaluator.php';
require('../utils/fpdf17/fpdf.php');
session_start() ;
?>
<html>
<head>
<style type="text/css">
body
{

font-family:"Calibri";}
}
</style>
</head>
<body>

<b>Did you mean this stock?</b>
<br /><br />
<?php


$stock = new stock;
$stock->get_stock_quote($_POST["symbol"]);
$result = $stock->pe * $stock->pb;
if((!is_numeric($stock->pe) || !is_numeric($stock->pb))){
	$res = "No advise <br>";
}
else if($result<= 22.5) 
	{
		$res = "<font color='green'>PASSED!<br /></font>";
	}
	else 
	{
		$res = "<font color='red'>FAILDED!<br /></font>";
	}



echo "<b>Name: </b>";
echo $stock->name;
echo "<br />";
echo "<b>Symbol: </b>";
echo $stock->symbol;
echo "<br />";
echo "<b>Stock exchange: </b>";
echo $stock->se;
echo "<br />";
echo "<b>Price:</b> ";
echo $stock->last;
echo "<br />";
echo "<b>52-week high:</b> ";
echo $stock->wh;
echo "<br />";
echo "<b>52-week low:</b> ";
echo $stock->wl;
echo "<br />";
echo "<b>Dividend/Share: </b>";
echo $stock->div;
echo "<br />";
echo "<b>EPS:</b> ";
echo $stock->eps;
echo "<br />";
echo "<b>EBITDA:</b> ";
echo $stock->ebitda;
echo "<br />";
echo "<br />";
echo "<b>P/E: </b>";
echo  "".addColor($stock->pe, 15)."";
echo "<br />";
echo "<b>P/B: </b>";
echo  "".addColor($stock->pb, 1.5)."";
echo "<br />";
echo "<b>First assesment: </b>";
echo "$res";







$evaluator = new Evaluator;
$evaluator->name = $stock->name;
$evaluator->ticker = $stock->symbol;
$evaluator->price = $stock->last;
$evaluator->exchange = $stock->se;

$_SESSION['evaluator'] = $evaluator;


function addColor($number, $reference){
	if($number <= $reference) 
	{
		$res = "<font color='green'>". $number . "</font>";
	}
	else 
	{
		$res = "<font color='red'>". $number . "</font>";
	}
	
	return $res;
}

?>



<br />
<button type="button" onclick="location.href='index.php'">Back</button>
<button type="button" onclick="location.href='step2.php'">Next</button>







</body>
</html>